home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / gengui2.lha / GenGui2 / Examples / bt.c < prev    next >
C/C++ Source or Header  |  1995-04-19  |  3KB  |  120 lines

  1.  
  2. /* This is for experimenting with backfill-hooks */
  3.  
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <proto/intuition.h>
  7. #include <intuition/intuition.h>
  8. #include <proto/exec.h>
  9. #include <proto/graphics.h>
  10. #include <proto/layers.h>
  11. #include <libraries/gadtools.h>
  12.  
  13. #include <graphics/gfxmacros.h>
  14.  
  15. extern struct IntuitionBase *IntuitionBase;
  16. extern struct GfxBase *GfxBase;
  17. extern struct Library *GadToolsBase;
  18.  
  19. struct LMsg {
  20.    struct Layer *Layer;
  21.    WORD   MinX,MinY;
  22.    WORD   MaxX,MaxY;
  23.    LONG OffsetX,OffsetY;
  24. } g[16];
  25.  
  26. struct Task *this;
  27. ULONG signal;
  28. USHORT readp,writep;
  29.  
  30. ULONG __interrupt __saveds __asm HookFunc(register __a0 struct Hook *hook,
  31.                                  register __a2 struct RastPort *rastport,
  32.                                  register __a1 struct LMsg *msg)
  33. {
  34.    struct RastPort rp=*rastport;
  35.  
  36.    static __chip USHORT bitmap[]={0xaaaa,0x5555,0xaaaa};
  37.  
  38.    rp.Layer=NULL;
  39.  
  40.    g[writep]=*msg;
  41.    writep=(writep+1)&15;
  42.  
  43.    Signal(this,signal);
  44.  
  45.    SetAPen(&rp,2);
  46.    SetBPen(&rp,0);
  47.    SetDrMd(&rp,JAM2);
  48.  
  49.    /* Adjust the pattern to the window position */
  50.  
  51.    if((msg->MinX ^ msg->MinY ^ msg->OffsetX ^ msg->OffsetY) & 1)
  52.                                          {SetAfPt(&rp,(bitmap+1),1);} else
  53.                                          {SetAfPt(&rp,bitmap,1);}
  54.  
  55.   /* RectFill(&rp,msg->MinX,msg->MinY,msg->MaxX,msg->MaxY);*/
  56.  
  57.  
  58.    SetAPen(&rp,1);
  59.  
  60.    Move(&rp,msg->MinX,msg->MinY);
  61.    Draw(&rp,msg->MaxX,msg->MaxY);
  62.  
  63.    return(0);
  64. }
  65.  
  66.  
  67. main()
  68. {
  69.    struct IntuiMessage *msg;
  70.    struct Window *win;
  71.    int run=1;
  72.  
  73.    struct Hook hook;
  74.  
  75.    hook.h_Entry=(HOOKFUNC)HookFunc;
  76.    hook.h_SubEntry=NULL;
  77.  
  78.    win=OpenWindowTags(NULL,
  79.             WA_Left,0,WA_Top,20,
  80.             WA_Width,300,WA_Height,100,
  81.             WA_Title,"Test",
  82.             WA_IDCMP,BUTTONIDCMP|IDCMP_CLOSEWINDOW|SLIDERIDCMP|
  83.                      IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW,
  84.             WA_Flags,WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
  85.                         |WFLG_SIMPLE_REFRESH
  86.                         |WFLG_CLOSEGADGET|WFLG_ACTIVATE,
  87.             WA_MinWidth,300,WA_MinHeight,100,
  88.             WA_MaxWidth,-1,WA_MaxHeight,-1,
  89.             WA_BackFill,&hook,
  90.             TAG_DONE );
  91.  
  92.    if(!win) exit(0);
  93.  
  94.    this=FindTask(0);
  95.    signal=1<<win->UserPort->mp_SigBit;
  96.  
  97.    Signal(this,signal);
  98.  
  99.    while(run) {
  100.       Wait(signal);
  101.  
  102.       while(readp!=writep) {
  103.          printf("%d %d %d %d %d %d\n",g[readp].MinX,g[readp].MinY,
  104.                                       g[readp].MaxX,g[readp].MaxY,
  105.                                       g[readp].OffsetX,g[readp].OffsetY);
  106.          readp=(readp+1)&15;
  107.       }
  108.  
  109.       while(msg=(void *)GetMsg(win->UserPort)) {
  110.          switch(msg->Class) {
  111.             case IDCMP_CLOSEWINDOW: run=0;
  112.                                     break;
  113.          }
  114.          ReplyMsg((void *)msg);
  115.       }
  116.    }
  117.    CloseWindow(win);
  118.    return(0);
  119. }
  120.